package com.example.datadashboard.enums;

/**
 * 人员状态枚举：0-有效，1-失效
 */
public enum UserStatusEnum {
    VALID(0, "有效"),
    INVALID(1, "失效");

    private final int code;
    private final String desc;

    UserStatusEnum(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public int getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public static UserStatusEnum fromCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (UserStatusEnum status : values()) {
            if (status.code == code) {
                return status;
            }
        }
        return null;
    }
}